<!DOCTYPE HTML>
<html lang="zh-CN">


<head>
    <meta charset="utf-8">
    <meta name="keywords" content="数据结构 第三章栈和队列, 十二惊惶的gitee">
    <meta name="description" content="判断题
若一个栈的输入序列为1，2，3，…，N，输出序列的第一个元素是i，则第j个输出元素是j−i−1。   (F)
栈的运算遵循后入先出的原则，输出的第一个是i，则第j个输出的应该是第i-j+1个元素。


所谓“循环队列”是指用单向循环">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
    <meta name="renderer" content="webkit|ie-stand|ie-comp">
    <meta name="mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
    <meta name="referrer" content="no-referrer-when-downgrade">
    <!-- Global site tag (gtag.js) - Google Analytics -->


    <title>数据结构 第三章栈和队列 | 十二惊惶的gitee</title>
    <link rel="icon" type="image/png" href="/shier_jinghuang/favicon.png">
    


    <!-- bg-cover style     -->



<link rel="stylesheet" type="text/css" href="/shier_jinghuang/libs/awesome/css/all.min.css">
<link rel="stylesheet" type="text/css" href="/shier_jinghuang/libs/materialize/materialize.min.css">
<link rel="stylesheet" type="text/css" href="/shier_jinghuang/libs/aos/aos.css">
<link rel="stylesheet" type="text/css" href="/shier_jinghuang/libs/animate/animate.min.css">
<link rel="stylesheet" type="text/css" href="/shier_jinghuang/libs/lightGallery/css/lightgallery.min.css">
<link rel="stylesheet" type="text/css" href="/shier_jinghuang/css/matery.css">
<link rel="stylesheet" type="text/css" href="/shier_jinghuang/css/my.css">
<link rel="stylesheet" type="text/css" href="/shier_jinghuang/css/dark.css" media="none" onload="if(media!='all')media='all'">




    <link rel="stylesheet" href="/shier_jinghuang/libs/tocbot/tocbot.css">
    <link rel="stylesheet" href="/shier_jinghuang/css/post.css">




    



    <script src="/shier_jinghuang/libs/jquery/jquery-3.6.0.min.js"></script>

<meta name="generator" content="Hexo 5.4.0"><link rel="alternate" href="/shier_jinghuang/atom.xml" title="十二惊惶的gitee" type="application/atom+xml">
</head>


<body>
    <header class="navbar-fixed">
    <nav id="headNav" class="bg-color nav-transparent">
        <div id="navContainer" class="nav-wrapper container">
            <div class="brand-logo">
                <a href="/shier_jinghuang/" class="waves-effect waves-light">
                    
                    <img src="/shier_jinghuang/medias/1.jpg" class="logo-img" alt="LOGO">
                    
                    <span class="logo-span">十二惊惶的gitee</span>
                </a>
            </div>
            

<a href="#" data-target="mobile-nav" class="sidenav-trigger button-collapse"><i class="fas fa-bars"></i></a>
<ul class="right nav-menu">
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/shier_jinghuang/" class="waves-effect waves-light">
      
      <i class="fas fa-home" style="zoom: 0.6;"></i>
      
      <span>首页</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/shier_jinghuang/tags" class="waves-effect waves-light">
      
      <i class="fas fa-tags" style="zoom: 0.6;"></i>
      
      <span>标签</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/shier_jinghuang/categories" class="waves-effect waves-light">
      
      <i class="fas fa-bookmark" style="zoom: 0.6;"></i>
      
      <span>分类</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/shier_jinghuang/archives" class="waves-effect waves-light">
      
      <i class="fas fa-archive" style="zoom: 0.6;"></i>
      
      <span>归档</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/shier_jinghuang/about" class="waves-effect waves-light">
      
      <i class="fas fa-user-circle" style="zoom: 0.6;"></i>
      
      <span>关于</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/shier_jinghuang/contact" class="waves-effect waves-light">
      
      <i class="fas fa-comments" style="zoom: 0.6;"></i>
      
      <span>留言板</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/shier_jinghuang/friends" class="waves-effect waves-light">
      
      <i class="fas fa-address-book" style="zoom: 0.6;"></i>
      
      <span>友情链接</span>
    </a>
    
  </li>
  
  <li>
    <a href="#searchModal" class="modal-trigger waves-effect waves-light">
      <i id="searchIcon" class="fas fa-search" title="搜索" style="zoom: 0.85;"></i>
    </a>
  </li>
  <li>
    <a href="javascript:;" class="waves-effect waves-light" onclick="switchNightMode()" title="深色/浅色模式" >
      <i id="sum-moon-icon" class="fas fa-sun" style="zoom: 0.85;"></i>
    </a>
  </li>
</ul>


<div id="mobile-nav" class="side-nav sidenav">

    <div class="mobile-head bg-color">
        
        <img src="/shier_jinghuang/medias/1.jpg" class="logo-img circle responsive-img">
        
        <div class="logo-name">十二惊惶的gitee</div>
        <div class="logo-desc">
            
            犁牛之子骍且角，虽欲勿用，山川其舍诸
            
        </div>
    </div>

    <ul class="menu-list mobile-menu-list">
        
        <li class="m-nav-item">
	  
		<a href="/shier_jinghuang/" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-home"></i>
			
			首页
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/shier_jinghuang/tags" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-tags"></i>
			
			标签
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/shier_jinghuang/categories" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-bookmark"></i>
			
			分类
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/shier_jinghuang/archives" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-archive"></i>
			
			归档
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/shier_jinghuang/about" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-user-circle"></i>
			
			关于
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/shier_jinghuang/contact" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-comments"></i>
			
			留言板
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/shier_jinghuang/friends" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-address-book"></i>
			
			友情链接
		</a>
          
        </li>
        
        
        <li><div class="divider"></div></li>
        <li>
            <a href="https://gitee.com/Im-so-scared-2/shier_jinghuang" class="waves-effect waves-light" target="_blank">
                <i class="fab fa-github-square fa-fw"></i>十二惊惶
            </a>
        </li>
        
    </ul>
</div>


        </div>

        
            <style>
    .nav-transparent .github-corner {
        display: none !important;
    }

    .github-corner {
        position: absolute;
        z-index: 10;
        top: 0;
        right: 0;
        border: 0;
        transform: scale(1.1);
    }

    .github-corner svg {
        color: #0f9d58;
        fill: #fff;
        height: 64px;
        width: 64px;
    }

    .github-corner:hover .octo-arm {
        animation: a 0.56s ease-in-out;
    }

    .github-corner .octo-arm {
        animation: none;
    }

    @keyframes a {
        0%,
        to {
            transform: rotate(0);
        }
        20%,
        60% {
            transform: rotate(-25deg);
        }
        40%,
        80% {
            transform: rotate(10deg);
        }
    }
</style>

<a href="https://gitee.com/Im-so-scared-2/shier_jinghuang" class="github-corner tooltipped hide-on-med-and-down" target="_blank"
   data-tooltip="十二惊惶" data-position="left" data-delay="50">
    <svg viewBox="0 0 250 250" aria-hidden="true">
        <path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path>
        <path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2"
              fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path>
        <path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z"
              fill="currentColor" class="octo-body"></path>
    </svg>
</a>
        
    </nav>

</header>

    



<div class="bg-cover pd-header post-cover" style="background-image: url('/shier_jinghuang/medias/featureimages/6.jpg')">
    <div class="container" style="right: 0px;left: 0px;">
        <div class="row">
            <div class="col s12 m12 l12">
                <div class="brand">
                    <h1 class="description center-align post-title">数据结构 第三章栈和队列</h1>
                </div>
            </div>
        </div>
    </div>
</div>




<main class="post-container content">

    
    <div class="row">
    <div id="main-content" class="col s12 m12 l9">
        <!-- 文章内容详情 -->
<div id="artDetail">
    <div class="card">
        <div class="card-content article-info">
            <div class="row tag-cate">
                <div class="col s7">
                    
                    <div class="article-tag">
                        
                            <a href="/shier_jinghuang/tags/%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84/">
                                <span class="chip bg-color">数据结构</span>
                            </a>
                        
                    </div>
                    
                </div>
                <div class="col s5 right-align">
                    
                </div>
            </div>

            <div class="post-info">
                
                <div class="post-date info-break-policy">
                    <i class="far fa-calendar-minus fa-fw"></i>发布日期:&nbsp;&nbsp;
                    2021-12-09
                </div>
                

                
                <div class="post-date info-break-policy">
                    <i class="far fa-calendar-check fa-fw"></i>更新日期:&nbsp;&nbsp;
                    2022-01-04
                </div>
                

                
                <div class="info-break-policy">
                    <i class="far fa-file-word fa-fw"></i>文章字数:&nbsp;&nbsp;
                    4.6k
                </div>
                

                
                <div class="info-break-policy">
                    <i class="far fa-clock fa-fw"></i>阅读时长:&nbsp;&nbsp;
                    19 分
                </div>
                

                
                    <div id="busuanzi_container_page_pv" class="info-break-policy">
                        <i class="far fa-eye fa-fw"></i>阅读次数:&nbsp;&nbsp;
                        <span id="busuanzi_value_page_pv"></span>
                    </div>
				
            </div>
        </div>
        <hr class="clearfix">

        
        <!-- 是否加载使用自带的 prismjs. -->
        <link rel="stylesheet" href="/shier_jinghuang/libs/prism/prism.min.css">
        

        

        <div class="card-content article-card-content">
            <div id="articleContent">
                <h1 id="判断题"><a href="#判断题" class="headerlink" title="判断题"></a>判断题</h1><ol>
<li>若一个栈的输入序列为1，2，3，…，N，输出序列的第一个元素是i，则第j个输出元素是j−i−1。   (F)<ul>
<li>栈的运算遵循后入先出的原则，输出的第一个是i，则第j个输出的应该是第i-j+1个元素。</li>
</ul>
</li>
<li>所谓“循环队列”是指用单向循环链表或者循环数组表示的队列。   (F)<ul>
<li>循环队列：队列采用顺序存储，并且数组是头尾相接的循环结构</li>
</ul>
</li>
<li>在对不带头结点的链队列作出队操作时，不会改变头指针的值。   (F)<ul>
<li>会改变，头指针变为相连的指针；</li>
</ul>
</li>
<li><h2 id="不论是入队列操作还是入栈操作-在顺序存储结构上都需要考虑”溢出”情况。-T"><a href="#不论是入队列操作还是入栈操作-在顺序存储结构上都需要考虑”溢出”情况。-T" class="headerlink" title="不论是入队列操作还是入栈操作,在顺序存储结构上都需要考虑”溢出”情况。   (T)"></a>不论是入队列操作还是入栈操作,在顺序存储结构上都需要考虑”溢出”情况。   (T)</h2></li>
<li>队列和栈都是运算受限的线性表，只允许在表的两端进行运算。  (F)<ul>
<li>队列在只允许在一端插入，在另一端删除，而队列只能在同一端进行操作。</li>
</ul>
</li>
<li>栈和队列的存储方式，既可以是顺序方式，也可以是链式方式。 </li>
<li>循环队列也存在着空间溢出问题。    (T)<ul>
<li>循环队列解决的是假溢出问题，由于循环队列的大小是固定的，仍会出现真溢出。</li>
</ul>
</li>
<li>循环队列执行出队操作时会引起大量元素的移动。 </li>
<li>栈是插入和删除只能在一端进行的线性表；队列是插入在一端进行，删除在另一端进行的线性表。 </li>
<li>在n个元素连续进栈以后，它们的出栈顺序和进栈顺序一定正好相反。 </li>
<li>环形队列中有多少个元素可以根据队首指针和队尾指针的值来计算。 </li>
<li>栈和队列的插入和删除操作特殊，所以，栈和队列是非线性结构。     (F)<ul>
<li>栈和队列都是运算受限的线性表。</li>
</ul>
</li>
<li>序列{1,2,3,4,5}依次入栈，则不可能得到{3,4,1,2,5}的出栈序列。   (T)<ul>
<li>由题1,2,3,4,5依次入栈，所以在第一个3出栈的时候1,2均已经入栈，又由于栈的运算遵循后入先出，2会比1更先出栈，故{3,4,1,2,5}的出栈序列不可能出现。</li>
</ul>
</li>
<li>队列中允许插入的一端叫队头，允许删除的一端叫队尾。     （F)</li>
</ol>
<h2 id="选择题"><a href="#选择题" class="headerlink" title="选择题"></a>选择题</h2><ol>
<li><p>若用大小为6的数组来实现循环队列，且当前<code>front</code>和<code>rear</code>的值分别为0和4。当从队列中删除两个元素，再加入两个元素后，<code>front</code>和<code>rear</code>的值分别为多少？   (A)</p>
<p>A.2和0            B.2和2            C.2和4       D.2和6</p>
<ul>
<li>有已知得，<code>front</code>和<code>rear</code>的值分别为0和4，又数组大小为6，所以值的范围为[0,5],先删除两个元素，在添加两个元素，<code>front</code>与<code>rear</code>的值分别加2，为2,0.</li>
</ul>
</li>
<li><p>如果循环队列用大小为<code>m</code>的数组表示，且用队头指针<code>front</code>和队列元素个数<code>size</code>代替一般循环队列中的<code>front</code>和<code>rear</code>指针来表示队列的范围，那么这样的循环队列可以容纳的元素个数最多为： </p>
<p>A.m-1           B. m           C.m+1           D.不能确定</p>
</li>
<li><p>以下数据结构中，（ ）是非线性数据结构。 (A)</p>
<p>A.树                B.字符串                C.队列                D.栈</p>
</li>
<li><p>设栈S和队列Q的初始状态均为空，元素{1, 2, 3, 4, 5, 6, 7}依次进入栈S。若每个元素出栈后立即进入队列Q，且7个元素出队的顺序是{2, 5, 6, 4, 7, 3, 1}，则栈S的容量至少是：(D) </p>
<p>A.1             B.2             C.3             D.4</p>
<ul>
<li>由题出栈顺序是2,5,6,4,7,3,1而入栈顺序是顺序，则在5出栈前栈内至少含有1,3,4,5,四个数据，由此栈的大小至少为4</li>
</ul>
</li>
<li><p>线性表、堆栈、队列的主要区别是什么？     (B)</p>
<p>A.线性表用指针，堆栈和队列用数组</p>
<p>B.堆栈和队列都是插入、删除受到约束的线性表</p>
<p>C.线性表和队列都可以用循环链表实现，但堆栈不能</p>
<p>D.堆栈和队列都不是线性结构，而线性表是</p>
</li>
<li><p>栈和队列的共同点( )。  (C)</p>
<p>A.都是先进先出                                          B.都是后进先出</p>
<p>C.只允许在端点处插入和删除元素           D.没有共同点</p>
</li>
<li><p>下列关于线性表,栈和队列叙述,错误的是( )。                      (A)</p>
<p>A.线性表是给定的n(n必须大于零)个元素组成的序列</p>
<p>B.线性表允许在表的任何位置进行插入和删除操作</p>
<p>C.栈只允许在一端进行插入和删除操作</p>
<p>D.队列只允许在一端进行插入一端进行删除</p>
</li>
<li><p>设用一个数组A[1……N]来存储一个栈，令A[N]为栈底，用整型变量T指示当前栈顶位置，A[T]为栈顶元素。当从栈中弹出一个元素时，变量T的变化为（ ）。 </p>
</li>
<li><p>链式栈与顺序栈相比，一个比较明显的优点是（ ）。 (B)</p>
<p>A.插入操作更加方便                                           B.通常不会出现栈满的情况</p>
<p>C.不会出现栈空的情况                                       D.删除操作更加方便</p>
</li>
<li><p>在循环顺序队列中，假设以少用一个存储单元的方法来区分队列判满和判空的条件，front和rear分别为队首和队尾指针，它们分别指向队首元素和队尾元素的下一个存储单元，队列的最大存储容量为maxSize，则队列的长度是（ ）。 </p>
</li>
<li><p>设栈S和队列Q的初始状态为空，元素e1、e2、e3、e4、e5、e6依次通过栈S，一个元素出栈后即进入队列Q，若6个元素出队的顺序是e2、e4、e3、e6、e5、e1，则栈S的容量至少应该是（　　 ）。<strong>提示：对于栈，可以全进再依次出；也可以进一个出一个；也可以进一部分，出一个，再进一部分；但是出栈之后，不能再入栈</strong>。       (A)</p>
<p>A.3           B.4           C.6           D.2</p>
</li>
<li><p>关于栈和队列的下列说法正确的是（）     (B)</p>
<p>A.栈的插入操作是在栈顶进行，插入时需将栈内所有元素后移；</p>
<p>B.栈是后进先出的结构，出栈时除了栈顶元素，其余元素无需移动；</p>
<p>C.循环队列的出队操作删除的是队头元素，采用循环队列存储时，其余队列元素均需要移动；</p>
<p>D.链队列的入队操作在表尾进行，操作时间与队列长度成正比</p>
</li>
<li><p>一个栈的入栈序列是a,b,c,d,e，则栈的出栈序列不可能的是（ ）。 C</p>
<p>A.edcba                     B.decba                     C.dceab                     D.abcde</p>
</li>
<li><p>在一个链表表示的队列中， f和r分别指向队列的头和尾。下列哪个操作能正确地将s结点插入到队列中：  (B)</p>
<p>A.f-&gt;next=s; f=s;                     B.r-&gt;next=s; r=s;</p>
<p>C.s-&gt;next=r; r=s;                     D.s-&gt;next=f; f=s;</p>
</li>
<li><p>栈和队列具有相同的。 (B)</p>
<p>A.抽象数据类型           B.逻辑结构           C.存储结构           D.运算</p>
</li>
<li><p>假定利用数组a[n]顺序存储一个栈，用top表示栈顶指针，用top==-1表示栈空，并已知栈未满，当元素x进栈时所执行的操作为（C）。 </p>
<p>A.a[–top]=x           B.a[top–]=x           C.a[++top]=x           D.a[top++]=x</p>
</li>
<li><p>队列的“先进先出”特性是指（B）。</p>
<p>Ⅰ.最后插入队列中的元素总是最后被删除<br>Ⅱ.当同时进行插入、删除操作时，总是插入操作优先<br>Ⅲ.每当有删除操作时，总要先做一次插入操作<br>Ⅳ.每次从队列中删除的总是最早插入的元素</p>
<p>A.Ⅰ       B.Ⅰ、Ⅳ       C.Ⅱ、Ⅲ       D.Ⅳ</p>
</li>
<li><p>已知循环队列存储在一维数组A[0…n-1]中，且队列非空时front和rear分别指向队头元素和队尾元素。若初始时队列为空，且要求第一个进入队列的元素存储在A[0]处，则初始时front和rear的值分别是（　）。 </p>
</li>
<li><p>执行函数时，其局部变量一般采用（　）进行存储。 (C)</p>
<p>A.树形结构           B.静态链表           C.栈结构           D.队列结构</p>
</li>
<li><p>对空栈 <em>S</em> 进行 Push 和 Pop 操作，入栈序列为 a, b, c, d, e，经过 Push, Push, Pop, Push, Pop, Push, Push, Pop 操作后，得到的出栈序列是： (D)</p>
<p>A.b, a, c                   B.b, a, e                   C.b, c, a                   D.b, c, e</p>
</li>
<li><p>用S表示入栈操作，X表示出栈操作，若元素入栈的顺序为1234，为了得到1342出栈顺序，相应的S和X的操作串为( )。 (D)</p>
<p>A.SXSSSXXX                     B.SXSXSXSX</p>
<p>C.SSSSXXXX                     D.SXSSXSXX</p>
</li>
</ol>
<h2 id="填空题"><a href="#填空题" class="headerlink" title="填空题"></a>填空题</h2><p> 4-1 栈的运算遵循  <code>后进先出</code></p>
<p> 4-2 以下运算实现在链队上的入队列，请在空白处用适当句子予以填充。</p>
<pre class="line-numbers language-c++" data-language="c++"><code class="language-c++">void EnQueue(QueptrTp *lq,DataType x)&#123;
       LqueueTp *p;
       p&#x3D;(LqueueTp *)malloc(sizeof(LqueueTp))
       p-&gt;data&#x3D;x; &#x2F;&#x2F; 1分
       p-&gt;next&#x3D;NULL;
       (lq-&gt;rear)-&gt;next&#x3D;p&#x2F;&#x2F; 1分;
       lq-&gt;rear&#x3D;p &#x2F;&#x2F; 1分;
 &#125;<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></code></pre>

<p> 4-3 以下运算实现在链栈上的初始化，请在空白处用请适当句子予以填充。</p>
<pre class="line-numbers language-c++" data-language="c++"><code class="language-c++">typedef struct Node&#123;
  DataType data;
  struct Node *next;
&#125;StackNode,*LStackTp;
void InitStack(LStackTp &amp;ls)&#123;
    ls&#x3D;NULL
&#125;&#x2F;&#x2F;3分;<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></code></pre>

<h2 id="函数题"><a href="#函数题" class="headerlink" title="函数题"></a>函数题</h2><h3> <center>舞伴问题 (20 分)</center></h3>
假设在周末舞会上，男士和女士们分别进入舞厅，各自排成一队。跳舞开始，依次从男队和女队队头各出一人配成舞伴，若两队初始人数不同，则较长那一队未配对者等待下一轮舞曲。现要求写一算法模拟上述舞伴配对问题。 你需要用队列操作实现上述算法。请完成下面5个函数的操作。 

<h4 id="函数接口定义："><a href="#函数接口定义：" class="headerlink" title="函数接口定义："></a>函数接口定义：</h4><pre class="line-numbers language-c++" data-language="c++"><code class="language-c++">int QueueLen(SqQueue Q);&#x2F;&#x2F;队列长度 
int EnQueue(SqQueue &amp;Q, Person e);&#x2F;&#x2F;加入队列 
int QueueEmpty(SqQueue &amp;Q);&#x2F;&#x2F;队列是否为空 
int DeQueue(SqQueue &amp;Q, Person &amp;e);&#x2F;&#x2F;出队列 
void DancePartner(Person dancer[], int num); &#x2F;&#x2F;配对舞伴 <span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span></span></code></pre>

<ul>
<li><code>Q</code>：队列</li>
<li><code>e</code>:参加舞会的人</li>
<li><code>dancer</code>:全部舞者</li>
<li><code>num</code>:参加舞会的人数</li>
</ul>
<p>**输入说明 先输入参加舞会人数，再分别输入参加舞会人的姓名和性别 **</p>
<p>**输出说明 先输出配对的男女舞伴，若队伍有剩人，则输出剩下人性别及剩下人数目。 **</p>
<h4 id="裁判测试程序样例："><a href="#裁判测试程序样例：" class="headerlink" title="裁判测试程序样例："></a>裁判测试程序样例：</h4><pre class="line-numbers language-c++" data-language="c++"><code class="language-c++">#include&lt;iostream&gt;
#define MAXQSIZE 100&#x2F;&#x2F;队列可能达到的最大长度
#define OK 1
#define ERROR 0
#define OVERFLOW -2
using namespace std;
typedef struct &#123;
    char name[20]; &#x2F;&#x2F;姓名
    char sex; &#x2F;&#x2F;性别，&#39;F&#39;表示女性，&#39;M&#39;表示男性
&#125; Person;
&#x2F;&#x2F;- - - - - 队列的顺序存储结构- - - - - 
typedef struct &#123;
    Person data[MAXQSIZE]; 
    int front; &#x2F;&#x2F;头指针
    int rear; &#x2F;&#x2F;尾指针
&#125; Queue;
typedef Queue *SqQueue;
SqQueue Mdancers, Fdancers; &#x2F;&#x2F;分别存放男士和女士入队者队列
int InitQueue(SqQueue &amp;Q);
void DestroyQueue(SqQueue &amp;q);
int QueueLen(SqQueue Q);&#x2F;&#x2F;队列长度 
int EnQueue(SqQueue &amp;Q, Person e);&#x2F;&#x2F;加入队列 
int QueueEmpty(SqQueue &amp;Q);&#x2F;&#x2F;队列是否为空 
int DeQueue(SqQueue &amp;Q, Person &amp;e);&#x2F;&#x2F;出队列 
void DancePartner(Person dancer[], int num); &#x2F;&#x2F;配对舞伴 
int main()&#123;
    int i;
    int n;
    Person dancer[MAXQSIZE];
    cin&gt;&gt;n;
    for(i&#x3D;0;i&lt;n;i++) cin&gt;&gt; dancer[i].name &gt;&gt; dancer[i].sex;
    InitQueue(Mdancers); &#x2F;&#x2F;男士队列初始化
    InitQueue(Fdancers); &#x2F;&#x2F;女士队列初始化
    cout &lt;&lt; &quot;The dancing partners are:&quot; &lt;&lt; endl;
    DancePartner(dancer, n);
    if (!QueueEmpty(Fdancers)) &#123; 
        cout &lt;&lt; &quot;F:&quot;&lt;&lt;QueueLen(Fdancers) ;
    &#125; else if (!QueueEmpty(Mdancers)) &#123; 
        cout &lt;&lt; &quot;M:&quot;&lt;&lt;QueueLen(Mdancers) ;
    &#125;
    DestroyQueue(Fdancers);
    DestroyQueue(Mdancers);
    return 0;
&#125;
int InitQueue(SqQueue &amp;Q) &#123;&#x2F;&#x2F;构造一个空队列Q
    Q &#x3D; new Queue; &#x2F;&#x2F;为队列分配一个最大容量为MAXSIZE的数组空间
    if (!Q-&gt;data)
        exit( OVERFLOW); &#x2F;&#x2F;存储分配失败
    Q-&gt;front &#x3D; Q-&gt;rear &#x3D; 0; &#x2F;&#x2F;头指针和尾指针置为零，队列为空
    return OK;
&#125;
void DestroyQueue(SqQueue &amp;q)
&#123;
    delete q;
&#125;
&#x2F;* 请在这里填写答案 *&#x2F;<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></code></pre>

<h4 id="AC代码"><a href="#AC代码" class="headerlink" title="AC代码"></a>AC代码</h4><pre class="line-numbers language-c++" data-language="c++"><code class="language-c++">int QueueLen(SqQueue Q)
&#123;
    return (Q-&gt;rear - Q-&gt;front + MAXQSIZE ) % MAXQSIZE;

&#125;;&#x2F;&#x2F;队列长度
int EnQueue(SqQueue &amp;Q, Person e)
&#123;
    Q-&gt;rear &#x3D; (Q-&gt;rear + 1)% MAXQSIZE;
    Q-&gt;data[Q-&gt;rear] &#x3D; e;

    return 0;
&#125;;&#x2F;&#x2F;加入队列
int QueueEmpty(SqQueue &amp;Q)
&#123;
    if(Q-&gt;rear&#x3D;&#x3D;Q-&gt;front)
    &#123;
        return 1;
    &#125;
    else return 0;
&#125;;&#x2F;&#x2F;队列是否为空
int DeQueue(SqQueue &amp;Q, Person &amp;e)
&#123;
    Q-&gt;front&#x3D;(Q-&gt;front+1)%MAXQSIZE;
    e&#x3D;Q-&gt;data[Q-&gt;front];
    return 0;
&#125;;&#x2F;&#x2F;出队列
void DancePartner(Person dancer[], int num)
&#123;
    for (int i&#x3D;0; i&lt;num; i++)
    &#123;
        if(dancer[i].sex&#x3D;&#x3D;&#39;F&#39;)
        &#123;
            EnQueue(Fdancers,dancer[i]);
        &#125;
        if(dancer[i].sex&#x3D;&#x3D;&#39;M&#39;)
        &#123;
            EnQueue(Mdancers,dancer[i]);
        &#125;
    &#125;
    while(QueueEmpty(Mdancers)!&#x3D;1&amp;&amp;QueueEmpty(Fdancers)!&#x3D;1)
    &#123;
        Person x,y;
        DeQueue(Mdancers, x);
        DeQueue(Fdancers, y);
        cout&lt;&lt;y.name&lt;&lt;&quot;  &quot;&lt;&lt;x.name&lt;&lt;endl;
    &#125;
&#125;; &#x2F;&#x2F;配对舞伴 <span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></code></pre>

<H3><CENTER>十进制转二进制（顺序栈设计和应用） (10 分)</CENTER></H3>
 设计一个顺序栈，并利用该顺序栈将给定的十进制整整数转换为二进制并输出。 

<h4 id="函数接口定义：-1"><a href="#函数接口定义：-1" class="headerlink" title="函数接口定义："></a>函数接口定义：</h4><pre class="line-numbers language-c++" data-language="c++"><code class="language-c++">#define MaxSize 100    &#x2F;* 栈最大容量 *&#x2F;
int top;        &#x2F;* 栈顶指针 *&#x2F;
int mystack[MaxSize];    &#x2F;* 顺序栈 *&#x2F;
&#x2F;*判栈是否为空，空返回true，非空返回false *&#x2F;
bool isEmpty();
&#x2F;* 元素x入栈 *&#x2F;
void Push(int x);
&#x2F;* 取栈顶元素 *&#x2F;
int getTop();
&#x2F;* 删除栈顶元素 *&#x2F;
void Pop();<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></code></pre>

<p> 其中 <code>MaxSize</code> 和 <code>top</code> 分别为栈的最大容量和栈顶指针。数组<code>mystack</code> 用来模拟顺序栈。请实现给出的<code>isEmpty</code>、<code>Push</code>、<code>getTop</code>和<code>Pop</code>这四个函数。 </p>
<h4 id="裁判测试程序样例：-1"><a href="#裁判测试程序样例：-1" class="headerlink" title="裁判测试程序样例："></a>裁判测试程序样例：</h4><pre class="line-numbers language-c++" data-language="c++"><code class="language-c++">#include &lt;bits&#x2F;stdc++.h&gt;
using namespace std;
#define MaxSize 100        &#x2F;* 栈最大容量 *&#x2F;
int top;                &#x2F;* 栈顶指针 *&#x2F;
int mystack[MaxSize];    &#x2F;* 顺序栈 *&#x2F;
&#x2F;*判栈是否为空，空返回true，非空返回false *&#x2F;
bool isEmpty();&#x2F;* 元素x入栈 *&#x2F;
void Push(int x);&#x2F;* 取栈顶元素 *&#x2F;
int getTop();&#x2F;* 删除栈顶元素 *&#x2F;
void Pop();&#x2F;* 十进制正整数转换为二进制 *&#x2F;
void dec2bin(int x) &#123;
    top &#x3D; -1;            &#x2F;* 初始化栈顶指针 *&#x2F;
    while (x) &#123;
        Push(x % 2);
        x &gt;&gt;&#x3D; 1;
    &#125;
    while (!isEmpty()) &#123;
        int t &#x3D; getTop();
        Pop();
        printf(&quot;%d&quot;, t);
    &#125;
    printf(&quot;\n&quot;);
&#125;
int main(int argc, char const *argv[])
&#123;
    int n;
    while (scanf(&quot;%d&quot;, &amp;n) !&#x3D; EOF) &#123;
        dec2bin(n);
    &#125;
    return 0;
&#125;
&#x2F;* 请在这里填写答案 *&#x2F;<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></code></pre>

<h4 id="AC代码："><a href="#AC代码：" class="headerlink" title="AC代码："></a>AC代码：</h4><pre class="line-numbers language-C++" data-language="C++"><code class="language-C++">bool isEmpty()
&#123;
    if (top &#x3D;&#x3D; -1) return true;
    else return false;
&#125;
void Push(int x)
&#123;
    if (top &#x3D;&#x3D; MaxSize - 1)
        return;
    else mystack[++top] &#x3D; x;
&#125;
int getTop()
&#123;
    if (top &#x3D;&#x3D; -1) return 0;
    else return mystack[top];
&#125;
void Pop()
&#123;
    if (top &#x3D;&#x3D; -1) return;
    else top--;
&#125;<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></code></pre>

<h2 id="编程题："><a href="#编程题：" class="headerlink" title="编程题："></a>编程题：</h2><h3><center>7-1 银行业务队列简单模拟 (25 分)</center></h3>
设某银行有A、B两个业务窗口，且处理业务的速度不一样，其中A窗口处理速度是B窗口的2倍 —— 即当A窗口每处理完2个顾客时，B窗口处理完1个顾客。给定到达银行的顾客序列，请按业务完成的顺序输出顾客序列。假定不考虑顾客先后到达的时间间隔，并且当不同窗口同时处理完2个顾客时，A窗口顾客优先输出。

<h3 id="输入格式"><a href="#输入格式" class="headerlink" title="输入格式:"></a>输入格式:</h3><p>输入为一行正整数，其中第1个数字N(≤1000)为顾客总数，后面跟着N位顾客的编号。编号为奇数的顾客需要到A窗口办理业务，为偶数的顾客则去B窗口。数字间以空格分隔。</p>
<h3 id="输出格式"><a href="#输出格式" class="headerlink" title="输出格式:"></a>输出格式:</h3><p>按业务处理完成的顺序输出顾客的编号。数字间以空格分隔，但最后一个编号后不能有多余的空格。</p>
<pre class="line-numbers language-c++" data-language="c++"><code class="language-c++">#include&lt;stdio.h&gt;
#include&lt;malloc.h&gt;
#include&lt;stdlib.h&gt;
int main()
&#123;
    int A[1000];
    int B[1000];
    int N;
    int a&#x3D;0, b&#x3D;0, temp;
    scanf(&quot;%d&quot;, &amp;N);
    for(int i&#x3D;0; i&lt;N; i++)&#123;
        scanf(&quot;%d&quot;, &amp;temp);
        if(temp % 2 &#x3D;&#x3D; 1)
            A[a++] &#x3D; temp;
        else
            B[b++] &#x3D; temp;
    &#125;
    int i &#x3D; 0, j &#x3D; 0;
    if(a &gt; 1)&#123;&#x2F;&#x2F;A有超过两个人，输出两个
        printf(&quot;%d %d&quot;, A[0], A[1]);
        i &#x3D; 2;
    &#125;
    else if(a &gt; 0)&#x2F;&#x2F;A有超过一个人，输出一个
        printf(&quot;%d&quot;, A[i++]);
    else if(b &gt; 0)&#x2F;&#x2F;A没人，B有人，输出B一个
        printf(&quot;%d&quot;, B[j++]);
 
    if(j &#x3D;&#x3D; 0)&#x2F;&#x2F;输出了A没输出B，输出一个B来控制输出一组
        printf(&quot; %d&quot;, B[j++]);
     
    while(i &lt; a &amp;&amp; j &lt; b)&#123;
        if(i+1 &lt; a)&#123;
            printf(&quot; %d %d&quot;,A[i], A[i+1]);
            i +&#x3D; 2;
        &#125;
        else
            printf(&quot; %d&quot;, A[i++]);
        printf(&quot; %d&quot;, B[j++]);
    &#125;
    while(i &lt; a)
        printf(&quot; %d&quot;, A[i++]);
    while(j &lt; b)
        printf(&quot; %d&quot;, B[j++]);
&#125;<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></code></pre>

<h3><center>7-2 堆栈操作合法性 (20 分)</center></h3>
假设以`S`和`X`分别表示入栈和出栈操作。如果根据一个仅由`S`和`X`构成的序列，对一个空堆栈进行操作，相应操作均可行（如没有出现删除时栈空）且最后状态也是栈空，则称该序列是合法的堆栈操作序列。请编写程序，输入`S`和`X`序列，判断该序列是否合法。

<h3 id="输入格式-1"><a href="#输入格式-1" class="headerlink" title="输入格式:"></a>输入格式:</h3><p>输入第一行给出两个正整数N和M，其中N是待测序列的个数，M（≤50）是堆栈的最大容量。随后N行，每行中给出一个仅由<code>S</code>和<code>X</code>构成的序列。序列保证不为空，且长度不超过100。</p>
<h3 id="输出格式-1"><a href="#输出格式-1" class="headerlink" title="输出格式:"></a>输出格式:</h3><p>对每个序列，在一行中输出<code>YES</code>如果该序列是合法的堆栈操作序列，或<code>NO</code>如果不是。</p>
<h3 id="输入样例："><a href="#输入样例：" class="headerlink" title="输入样例："></a>输入样例：</h3><pre class="line-numbers language-in" data-language="in"><code class="language-in">4 10
SSSXXSXXSX
SSSXXSXXS
SSSSSSSSSSXSSXXXXXXXXXXX
SSSXXSXXX结尾无空行<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span></span></code></pre>

<h3 id="输出样例："><a href="#输出样例：" class="headerlink" title="输出样例："></a>输出样例：</h3><pre class="line-numbers language-out" data-language="out"><code class="language-out">YES
NO
NO
NO结尾无空行<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span></span></code></pre>

<pre class="line-numbers language-c++" data-language="c++"><code class="language-c++">#include &lt;iostream&gt;
using namespace std;
int main() &#123;
	int N, M;
	cin &gt;&gt; N &gt;&gt; M;
	while (N--) &#123;
		string a;
		int cnt &#x3D; 0, flag &#x3D; 1;
		cin &gt;&gt; a;
		for (int i &#x3D; 0; i &lt; a.size(); ++i)
			if (a[i] &#x3D;&#x3D; &#39;S&#39;) &#123;
				cnt++;
				if (cnt &gt; M) &#123;
					flag &#x3D; 0;
					cout &lt;&lt; &quot;NO&quot; &lt;&lt; endl;
					break;
				&#125;
			&#125;
			else &#123;
				cnt--;
				if (cnt &lt; 0) &#123;
					flag &#x3D; 0;
					cout &lt;&lt; &quot;NO&quot; &lt;&lt; endl;
					break;
				&#125;
			&#125;
		if (flag)
			cout &lt;&lt; (cnt &#x3D;&#x3D; 0 ? &quot;YES&quot; : &quot;NO&quot;) &lt;&lt; endl;
	&#125;
	return 0;
&#125;<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></code></pre>


                
            </div>
            <hr/>

            

    <div class="reprint" id="reprint-statement">
        
            <div class="reprint__author">
                <span class="reprint-meta" style="font-weight: bold;">
                    <i class="fas fa-user">
                        文章作者:
                    </i>
                </span>
                <span class="reprint-info">
                    <a href="/shier_jinghuang/about" rel="external nofollow noreferrer">十二惊惶</a>
                </span>
            </div>
            <div class="reprint__type">
                <span class="reprint-meta" style="font-weight: bold;">
                    <i class="fas fa-link">
                        文章链接:
                    </i>
                </span>
                <span class="reprint-info">
                    <a href="https://im-so-scared-2.gitee.io/shier_jinghuang/shier_jinghuang/2021/12/09/%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84%E7%AC%AC%E4%B8%89%E7%AB%A0%E6%A0%88%E5%92%8C%E9%98%9F%E5%88%97/">https://im-so-scared-2.gitee.io/shier_jinghuang/shier_jinghuang/2021/12/09/%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84%E7%AC%AC%E4%B8%89%E7%AB%A0%E6%A0%88%E5%92%8C%E9%98%9F%E5%88%97/</a>
                </span>
            </div>
            <div class="reprint__notice">
                <span class="reprint-meta" style="font-weight: bold;">
                    <i class="fas fa-copyright">
                        版权声明:
                    </i>
                </span>
                <span class="reprint-info">
                    本博客所有文章除特別声明外，均采用
                    <a href="https://creativecommons.org/licenses/by/4.0/deed.zh" rel="external nofollow noreferrer" target="_blank">CC BY 4.0</a>
                    许可协议。转载请注明来源
                    <a href="/shier_jinghuang/about" target="_blank">十二惊惶</a>
                    !
                </span>
            </div>
        
    </div>

    <script async defer>
      document.addEventListener("copy", function (e) {
        let toastHTML = '<span>复制成功，请遵循本文的转载规则</span><button class="btn-flat toast-action" onclick="navToReprintStatement()" style="font-size: smaller">查看</a>';
        M.toast({html: toastHTML})
      });

      function navToReprintStatement() {
        $("html, body").animate({scrollTop: $("#reprint-statement").offset().top - 80}, 800);
      }
    </script>



            <div class="tag_share" style="display: block;">
                <div class="post-meta__tag-list" style="display: inline-block;">
                    
                        <div class="article-tag">
                            
                                <a href="/shier_jinghuang/tags/%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84/">
                                    <span class="chip bg-color">数据结构</span>
                                </a>
                            
                        </div>
                    
                </div>
                <div class="post_share" style="zoom: 80%; width: fit-content; display: inline-block; float: right; margin: -0.15rem 0;">
                    <link rel="stylesheet" type="text/css" href="/shier_jinghuang/libs/share/css/share.min.css">
<div id="article-share">

    
    <div class="social-share" data-sites="twitter,facebook,google,qq,qzone,wechat,weibo,douban,linkedin" data-wechat-qrcode-helper="<p>微信扫一扫即可分享！</p>"></div>
    <script src="/shier_jinghuang/libs/share/js/social-share.min.js"></script>
    

    

</div>

                </div>
            </div>
            
        </div>
    </div>

    

    

    

    

    

    

    

    

    

<article id="prenext-posts" class="prev-next articles">
    <div class="row article-row">
        
        <div class="article col s12 m6" data-aos="fade-up">
            <div class="article-badge left-badge text-color">
                <i class="fas fa-chevron-left"></i>&nbsp;上一篇</div>
            <div class="card">
                <a href="/shier_jinghuang/2022/01/10/Matlab/">
                    <div class="card-image">
                        
                        
                        <img src="/shier_jinghuang/medias/featureimages/7.jpg" class="responsive-img" alt="Matlab入门(一)">
                        
                        <span class="card-title">Matlab入门(一)</span>
                    </div>
                </a>
                <div class="card-content article-content">
                    <div class="summary block-with-text">
                        
                            
                        
                    </div>
                    <div class="publish-info">
                        <span class="publish-date">
                            <i class="far fa-clock fa-fw icon-date"></i>2022-01-10
                        </span>
                        <span class="publish-author">
                            
                            <i class="fas fa-bookmark fa-fw icon-category"></i>
                            
                            <a href="/shier_jinghuang/categories/%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0/" class="post-category">
                                    学习笔记
                                </a>
                            
                            
                        </span>
                    </div>
                </div>
                
                <div class="card-action article-tags">
                    
                    <a href="/shier_jinghuang/tags/%E5%AD%A6%E4%B9%A0%E8%AE%B0%E5%BD%95/">
                        <span class="chip bg-color">学习记录</span>
                    </a>
                    
                    <a href="/shier_jinghuang/tags/Matlab/">
                        <span class="chip bg-color">Matlab</span>
                    </a>
                    
                </div>
                
            </div>
        </div>
        
        
        <div class="article col s12 m6" data-aos="fade-up">
            <div class="article-badge right-badge text-color">
                下一篇&nbsp;<i class="fas fa-chevron-right"></i>
            </div>
            <div class="card">
                <a href="/shier_jinghuang/2021/12/03/BJDCTF2020/">
                    <div class="card-image">
                        
                        
                        <img src="/shier_jinghuang/medias/featureimages/3.jpg" class="responsive-img" alt="BJDCTF2020">
                        
                        <span class="card-title">BJDCTF2020</span>
                    </div>
                </a>
                <div class="card-content article-content">
                    <div class="summary block-with-text">
                        
                            
                        
                    </div>
                    <div class="publish-info">
                            <span class="publish-date">
                                <i class="far fa-clock fa-fw icon-date"></i>2021-12-03
                            </span>
                        <span class="publish-author">
                            
                            <i class="fas fa-bookmark fa-fw icon-category"></i>
                            
                            <a href="/shier_jinghuang/categories/CTF/" class="post-category">
                                    CTF
                                </a>
                            
                            
                        </span>
                    </div>
                </div>
                
                <div class="card-action article-tags">
                    
                    <a href="/shier_jinghuang/tags/%E8%A7%A3%E9%A2%98%E8%AE%B0%E5%BD%95/">
                        <span class="chip bg-color">解题记录</span>
                    </a>
                    
                </div>
                
            </div>
        </div>
        
    </div>
</article>

</div>



<!-- 代码块功能依赖 -->
<script type="text/javascript" src="/shier_jinghuang/libs/codeBlock/codeBlockFuction.js"></script>


  <!-- 是否加载使用自带的 prismjs. -->
  <script type="text/javascript" src="/shier_jinghuang/libs/prism/prism.min.js"></script>


<!-- 代码语言 -->

<script type="text/javascript" src="/shier_jinghuang/libs/codeBlock/codeLang.js"></script>


<!-- 代码块复制 -->

<script type="text/javascript" src="/shier_jinghuang/libs/codeBlock/codeCopy.js"></script>


<!-- 代码块收缩 -->

<script type="text/javascript" src="/shier_jinghuang/libs/codeBlock/codeShrink.js"></script>



    </div>
    <div id="toc-aside" class="expanded col l3 hide-on-med-and-down">
        <div class="toc-widget card" style="background-color: white;">
            <div class="toc-title"><i class="far fa-list-alt"></i>&nbsp;&nbsp;目录</div>
            <div id="toc-content"></div>
        </div>
    </div>
</div>

<!-- TOC 悬浮按钮. -->

<div id="floating-toc-btn" class="hide-on-med-and-down">
    <a class="btn-floating btn-large bg-color">
        <i class="fas fa-list-ul"></i>
    </a>
</div>


<script src="/shier_jinghuang/libs/tocbot/tocbot.min.js"></script>
<script>
    $(function () {
        tocbot.init({
            tocSelector: '#toc-content',
            contentSelector: '#articleContent',
            headingsOffset: -($(window).height() * 0.4 - 45),
            collapseDepth: Number('0'),
            headingSelector: 'h2, h3, h4'
        });

        // Set scroll toc fixed.
        let tocHeight = parseInt($(window).height() * 0.4 - 64);
        let $tocWidget = $('.toc-widget');
        $(window).scroll(function () {
            let scroll = $(window).scrollTop();
            /* add post toc fixed. */
            if (scroll > tocHeight) {
                $tocWidget.addClass('toc-fixed');
            } else {
                $tocWidget.removeClass('toc-fixed');
            }
        });

        
        /* 修复文章卡片 div 的宽度. */
        let fixPostCardWidth = function (srcId, targetId) {
            let srcDiv = $('#' + srcId);
            if (srcDiv.length === 0) {
                return;
            }

            let w = srcDiv.width();
            if (w >= 450) {
                w = w + 21;
            } else if (w >= 350 && w < 450) {
                w = w + 18;
            } else if (w >= 300 && w < 350) {
                w = w + 16;
            } else {
                w = w + 14;
            }
            $('#' + targetId).width(w);
        };

        // 切换TOC目录展开收缩的相关操作.
        const expandedClass = 'expanded';
        let $tocAside = $('#toc-aside');
        let $mainContent = $('#main-content');
        $('#floating-toc-btn .btn-floating').click(function () {
            if ($tocAside.hasClass(expandedClass)) {
                $tocAside.removeClass(expandedClass).hide();
                $mainContent.removeClass('l9');
            } else {
                $tocAside.addClass(expandedClass).show();
                $mainContent.addClass('l9');
            }
            fixPostCardWidth('artDetail', 'prenext-posts');
        });
        
    });
</script>

    

</main>




    <footer class="page-footer bg-color">
    
        <link rel="stylesheet" href="/shier_jinghuang/libs/aplayer/APlayer.min.css">
<style>
    .aplayer .aplayer-lrc p {
        
        display: none;
        
        font-size: 12px;
        font-weight: 700;
        line-height: 16px !important;
    }

    .aplayer .aplayer-lrc p.aplayer-lrc-current {
        
        display: none;
        
        font-size: 15px;
        color: #42b983;
    }

    
    .aplayer.aplayer-fixed.aplayer-narrow .aplayer-body {
        left: -66px !important;
    }

    .aplayer.aplayer-fixed.aplayer-narrow .aplayer-body:hover {
        left: 0px !important;
    }

    
</style>
<div class="">
    
    <div class="row">
        <meting-js class="col l8 offset-l2 m10 offset-m1 s12"
                   server="netease"
                   type="playlist"
                   id="503838841"
                   fixed='true'
                   autoplay='false'
                   theme='#42b983'
                   loop='all'
                   order='random'
                   preload='auto'
                   volume='0.7'
                   list-folded='true'
        >
        </meting-js>
    </div>
</div>

<script src="/shier_jinghuang/libs/aplayer/APlayer.min.js"></script>
<script src="/shier_jinghuang/libs/aplayer/Meting.min.js"></script>

    

    <div class="container row center-align"
         style="margin-bottom: 0px !important;">
        <div class="col s12 m8 l8 copy-right">
            Copyright&nbsp;&copy;
            
                <span id="year">2019-2023</span>
            
            <a href="/shier_jinghuang/about" target="_blank">十二惊惶</a>
            |&nbsp;Powered by&nbsp;<a href="https://hexo.io/" target="_blank">Hexo</a>
            |&nbsp;Theme&nbsp;<a href="https://github.com/blinkfox/hexo-theme-matery" target="_blank">Matery</a>
            <br>
            
                &nbsp;<i class="fas fa-chart-area"></i>&nbsp;站点总字数:&nbsp;<span
                        class="white-color">289.6k</span>
            
            
            
                
            
            
                <span id="busuanzi_container_site_pv">
                &nbsp;|&nbsp;<i class="far fa-eye"></i>&nbsp;总访问量:&nbsp;
                    <span id="busuanzi_value_site_pv" class="white-color"></span>
            </span>
            
            
                <span id="busuanzi_container_site_uv">
                &nbsp;|&nbsp;<i class="fas fa-users"></i>&nbsp;总访问人数:&nbsp;
                    <span id="busuanzi_value_site_uv" class="white-color"></span>
            </span>
            
            <br>

            <!-- 运行天数提醒. -->
            
            <br>
            
        </div>
        <div class="col s12 m4 l4 social-link social-statis">
    <a href="https://github.com/blinkfox" class="tooltipped" target="_blank" data-tooltip="访问我的GitHub" data-position="top" data-delay="50">
        <i class="fab fa-github"></i>
    </a>



    <a href="mailto:1181062873@qq.com" class="tooltipped" target="_blank" data-tooltip="邮件联系我" data-position="top" data-delay="50">
        <i class="fas fa-envelope-open"></i>
    </a>







    <a href="tencent://AddContact/?fromId=50&fromSubId=1&subcmd=all&uin=1181062873" class="tooltipped" target="_blank" data-tooltip="QQ联系我: 1181062873" data-position="top" data-delay="50">
        <i class="fab fa-qq"></i>
    </a>







    <a href="/shier_jinghuang/atom.xml" class="tooltipped" target="_blank" data-tooltip="RSS 订阅" data-position="top" data-delay="50">
        <i class="fas fa-rss"></i>
    </a>

</div>
    </div>
</footer>

<div class="progress-bar"></div>


    <!-- 搜索遮罩框 -->
<div id="searchModal" class="modal">
    <div class="modal-content">
        <div class="search-header">
            <span class="title"><i class="fas fa-search"></i>&nbsp;&nbsp;搜索</span>
            <input type="search" id="searchInput" name="s" placeholder="请输入搜索的关键字"
                   class="search-input">
        </div>
        <div id="searchResult"></div>
    </div>
</div>

<script type="text/javascript">
$(function () {
    var searchFunc = function (path, search_id, content_id) {
        'use strict';
        $.ajax({
            url: path,
            dataType: "xml",
            success: function (xmlResponse) {
                // get the contents from search data
                var datas = $("entry", xmlResponse).map(function () {
                    return {
                        title: $("title", this).text(),
                        content: $("content", this).text(),
                        url: $("url", this).text()
                    };
                }).get();
                var $input = document.getElementById(search_id);
                var $resultContent = document.getElementById(content_id);
                $input.addEventListener('input', function () {
                    var str = '<ul class=\"search-result-list\">';
                    var keywords = this.value.trim().toLowerCase().split(/[\s\-]+/);
                    $resultContent.innerHTML = "";
                    if (this.value.trim().length <= 0) {
                        return;
                    }
                    // perform local searching
                    datas.forEach(function (data) {
                        var isMatch = true;
                        var data_title = data.title.trim().toLowerCase();
                        var data_content = data.content.trim().replace(/<[^>]+>/g, "").toLowerCase();
                        var data_url = data.url;
                        data_url = data_url.indexOf('/') === 0 ? data.url : '/' + data_url;
                        var index_title = -1;
                        var index_content = -1;
                        var first_occur = -1;
                        // only match artiles with not empty titles and contents
                        if (data_title !== '' && data_content !== '') {
                            keywords.forEach(function (keyword, i) {
                                index_title = data_title.indexOf(keyword);
                                index_content = data_content.indexOf(keyword);
                                if (index_title < 0 && index_content < 0) {
                                    isMatch = false;
                                } else {
                                    if (index_content < 0) {
                                        index_content = 0;
                                    }
                                    if (i === 0) {
                                        first_occur = index_content;
                                    }
                                }
                            });
                        }
                        // show search results
                        if (isMatch) {
                            str += "<li><a href='" + data_url + "' class='search-result-title'>" + data_title + "</a>";
                            var content = data.content.trim().replace(/<[^>]+>/g, "");
                            if (first_occur >= 0) {
                                // cut out 100 characters
                                var start = first_occur - 20;
                                var end = first_occur + 80;
                                if (start < 0) {
                                    start = 0;
                                }
                                if (start === 0) {
                                    end = 100;
                                }
                                if (end > content.length) {
                                    end = content.length;
                                }
                                var match_content = content.substr(start, end);
                                // highlight all keywords
                                keywords.forEach(function (keyword) {
                                    var regS = new RegExp(keyword, "gi");
                                    match_content = match_content.replace(regS, "<em class=\"search-keyword\">" + keyword + "</em>");
                                });

                                str += "<p class=\"search-result\">" + match_content + "...</p>"
                            }
                            str += "</li>";
                        }
                    });
                    str += "</ul>";
                    $resultContent.innerHTML = str;
                });
            }
        });
    };

    searchFunc('/shier_jinghuang/search.xml', 'searchInput', 'searchResult');
});
</script>

    <!-- 白天和黑夜主题 -->
<div class="stars-con">
    <div id="stars"></div>
    <div id="stars2"></div>
    <div id="stars3"></div>  
</div>

<script>
    function switchNightMode() {
        $('<div class="Cuteen_DarkSky"><div class="Cuteen_DarkPlanet"></div></div>').appendTo($('body')),
        setTimeout(function () {
            $('body').hasClass('DarkMode') 
            ? ($('body').removeClass('DarkMode'), localStorage.setItem('isDark', '0'), $('#sum-moon-icon').removeClass("fa-sun").addClass('fa-moon')) 
            : ($('body').addClass('DarkMode'), localStorage.setItem('isDark', '1'), $('#sum-moon-icon').addClass("fa-sun").removeClass('fa-moon')),
            
            setTimeout(function () {
            $('.Cuteen_DarkSky').fadeOut(1e3, function () {
                $(this).remove()
            })
            }, 2e3)
        })
    }
</script>

    <!-- 回到顶部按钮 -->
<div id="backTop" class="top-scroll">
    <a class="btn-floating btn-large waves-effect waves-light" href="#!">
        <i class="fas fa-arrow-up"></i>
    </a>
</div>


    <script src="/shier_jinghuang/libs/materialize/materialize.min.js"></script>
    <script src="/shier_jinghuang/libs/masonry/masonry.pkgd.min.js"></script>
    <script src="/shier_jinghuang/libs/aos/aos.js"></script>
    <script src="/shier_jinghuang/libs/scrollprogress/scrollProgress.min.js"></script>
    <script src="/shier_jinghuang/libs/lightGallery/js/lightgallery-all.min.js"></script>
    <script src="/shier_jinghuang/js/matery.js"></script>

    

    

    <!-- 雪花特效 -->
    

    <!-- 鼠标星星特效 -->
    

     
        <script src="https://ssl.captcha.qq.com/TCaptcha.js"></script>
        <script src="/shier_jinghuang/libs/others/TencentCaptcha.js"></script>
        <button id="TencentCaptcha" data-appid="xxxxxxxxxx" data-cbfn="callback" type="button" hidden></button>
    

    <!-- Baidu Analytics -->

    <!-- Baidu Push -->

<script>
    (function () {
        var bp = document.createElement('script');
        var curProtocol = window.location.protocol.split(':')[0];
        if (curProtocol === 'https') {
            bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';
        } else {
            bp.src = 'http://push.zhanzhang.baidu.com/push.js';
        }
        var s = document.getElementsByTagName("script")[0];
        s.parentNode.insertBefore(bp, s);
    })();
</script>

    
    <script src="/shier_jinghuang/libs/others/clicklove.js" async="async"></script>
    
    
    <script async src="/shier_jinghuang/libs/others/busuanzi.pure.mini.js"></script>
    

    

    

    <!--腾讯兔小巢-->
    
    

    

    

    
    <script src="/shier_jinghuang/libs/instantpage/instantpage.js" type="module"></script>
    

</body>

</html>
